package com.cloudptt.api.comm;

import android.content.Context;

import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;

public class IniFileParser {
    private Context ctx = null;
    private  Properties properties = null;
    public IniFileParser(Context ctx)
    {
        this.ctx = ctx;
    }
    public void readFrom(String filename) {
        properties = new Properties();
        try {
//            fileInputStream = ctx.openFileInput(filename);
            File file = new File(filename);
            FileInputStream fis = new FileInputStream(file);
            properties.load(fis);
            fis.close();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
//        finally {
//            fileInputStream.close();
//        }
    }

    public String getStringKey(String key) {
        if (properties.containsKey(key) == false) {
            return null;
        }
        if(properties.get(key) != null)
        {
            String val = String.valueOf(properties.get(key));
            return val.trim();
        }
        return null;
    }

}
